package com.example.rentsystem.utils;

import org.apache.commons.fileupload.FileItem;

import java.io.File;
import java.util.UUID;

public class ImageUtil {

    // 保存图片的位置
    private static final String url = "D:/all/idea/RentSystem/assets/images/";

    public static boolean write(FileItem file, UUID uuid) {
        try {
            file.write(new File(url + uuid.toString() + ".jpg"));
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }


    public static boolean delete(String path) {
        return new File(url.replace("/assets/images/", "") + path).delete();
    }
}
